package com.jiangyg.mall.core.enums;

import org.apache.commons.lang.StringUtils;

/**
 * 枚举描述：逻辑关系
 *
 * @author jiangyg
 * @version 2.0
 * @date 2019-10-17
 */
public enum Logic {

    AND("and", "并且"), OR("or", "或者");

    /**
     * 代码
     */
    public final String code;

    /**
     * 名称
     */
    public final String name;

    Logic(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 功能描述：根据代码判断值
     *
     * @param code 代码
     * @return Enable
     */
    public static Logic decide(String code) {
        for (Logic logic : Logic.values()) {
            if (StringUtils.equalsIgnoreCase(code, logic.code)) {
                return logic;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return "Logic [code=" + this.code + ", name=" + this.name + "]";
    }

}
